package com.whq.mvc.base.enumtype;

/**
 * @Description: 星期枚举类
 * @Author: whq
 * @Date: 2021/8/29 10:39
 */
public enum WeekEnum {
    MONDAY(1, "周一"), TUESDAY(2, "周二"), WEDNESDAY(3, "周三"),
    THURSDAY(4, "周四"), FRIDAY(5, "周五"), SATURDAY(6, "周六"), SUNDAY(7, "周日");

    private Integer code;

    private String data;

    WeekEnum(Integer code, String data) {
        this.code = code;
        this.data = data;
    }

    public String getData() {
        return data;
    }

    public Integer getCode() {
        return code;
    }

    public static WeekEnum from(Integer code) {
        switch (code) {
            case 1:
                return MONDAY;
            case 2:
                return TUESDAY;
            case 3:
                return WEDNESDAY;
            case 4:
                return THURSDAY;
            case 5:
                return FRIDAY;
            case 6:
                return SATURDAY;
            case 7:
                return SUNDAY;
            default:
                throw new RuntimeException("code错误");
        }
    }
}
